﻿using Core.Dtos;
using Core.IServices;
using Core.Messages;
using Core.ViewModels;
using Core.Mappers;
using Library.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Services
{
    public class StaticService : BaseService, IStaticService
    {
        private readonly IReadDictionaryService dictionaryService;
        private readonly IReadLocalizationService localizationService;
        private readonly IReadSettingService settingService;
        private readonly IReadCultureService cultureService;

        public StaticService(IReadDictionaryService dictionaryService, IReadLocalizationService localizationService, IReadSettingService settingService, IReadCultureService cultureService)
        {
            this.dictionaryService = dictionaryService;
            this.localizationService = localizationService;
            this.settingService = settingService;
            this.cultureService = cultureService;
        }

        public Response<ClientContextVM> GetClientContext()
        {
            return Run<ClientContextVM>(() =>
            {
                ClientContextVM vm = new ClientContextVM();                                
                vm.Dictionaries = dictionaryService.GetAllItems();
                vm.LocaleStrings = localizationService.GetAllForClient();
                vm.Cultures = cultureService.GetAll();
                vm.Settings = settingService.GetAllForClient();
                return vm;
            });
        }
    }
}
